﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Security.Principal;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NoteSystem
{
    public partial class Master : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取session 取到头像和姓名 分别赋给image组件的imageurl和label.Text
            #region 管理员权限验证
            if (Session["User"] != null)
            {
                DataRow userRow = (DataRow)Session["User"];
                Image1.ImageUrl= userRow["img_url"].ToString();
                Label1.Text = userRow["account"].ToString();
                //查到登录用户的权限
                int manage = Convert.ToInt32(userRow["manager"]);
                if (manage == 0)
                {
                    lbtnUserManage.Visible = false;
                    liUserManager.Visible = false;
                }
                #endregion
            }
        }
        #region 退出
        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            //1.清Session
            Session["User"] = null;
            //2.删cookie
            HttpCookie accoutCookie = new HttpCookie("account");
            accoutCookie.Value = null;
            accoutCookie.Expires = DateTime.Now.AddDays(-1);
            HttpCookie pwdCookie = new HttpCookie("pwd");
            pwdCookie.Value = null;
            pwdCookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(accoutCookie);
            Response.Cookies.Add(pwdCookie);
            Response.Redirect("Login.aspx");
        }
        #endregion

        protected void lbtnUserManage_Click(object sender, EventArgs e)
        {
            Response.Redirect("User.aspx");
        }

        protected void lbtnLeftUserManage_Click(object sender, EventArgs e)
        {
            Response.Redirect("User.aspx");
        }
    }
}